package com.changgou.rabbitmq.listener;

import com.changgou.common.constant.RabbitMQConstant;
import com.changgou.common.dto.Message;
import com.changgou.item.feign.PageFeign;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemPageMessageListener {

    @Autowired
    private PageFeign pageFeign;

    @RabbitListener(queues = RabbitMQConstant.SPU_TOPIC_QUEUE)
    public void receive(Message message){
        //商品spu id
        Long spuId=Long.parseLong(message.getContent().toString());

        if (Message.TYPE_GOODS_AUDIT.equals(message.getType())){
            //审核通过；则生成页面
            pageFeign.createHtml(spuId);
        }else {
            //删除页面
            pageFeign.deleteHtml(spuId);
        }
    }
}
